const  url  = require('url');
const {URLSearchParams} = require('url');

let params = new URLSearchParams();
params.set('k','关键字');
params.set('p',1);

console.log(params.toString());


//      https://zhuanlan.zhihu.com/p/29581070

const params2 = new URLSearchParams('k=%E5%85%B3%E9%94%AE%E5%AD%97&p=1');
console.log(url.parse('https://zhuanlan.zhihu.com?k=267&p=1/29581070'));
urlString = url.parse('https://zhuanlan.zhihu.com?k=267&p=1/29581070');
const params3 = new URLSearchParams('https://zhuanlan.zhihu.com?k=267&p=1/29581070');
const params4 = new URLSearchParams(urlString.search);
console.log(params2.get('k'));
console.log(params2.get('p'));
console.log(params3.get('k'));
console.log(params3.get('p'));
console.log(params4.get('k'));
console.log();
console.log();
console.log();
console.log();

